package com.controller;

import com.feign.SmsFeignApi;
import com.feign.UserInfoFeignApi;
import com.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sms")
public class SmsController {

    @Autowired
    private SmsFeignApi smsFeignApi;

    @GetMapping("/sendVerifyCode")
    public JsonResult sendVerifyCode(String phone){
        //调用 msg-server 服务接口进行短信发送
        JsonResult result = smsFeignApi.sendVerifyCode(phone);
        //约定表示降级方法执行的结果是result为null，即如果result为null，说明是降级方法
        if (result == null){
            return JsonResult.defaultError();
        }
        return result;
    }
}